<%-- 
    Document   : displayQuestion
    Created on : Oct 28, 2009, 4:32:52 PM
    Author     : Administrator
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.sql.*" %>
<%@taglib prefix="ajax" uri="http://ajaxtags.org/tags/ajax" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <jsp:include page="../header.jsp" />
        <link rel="stylesheet" href="../css/style.css" />
        <link rel="stylesheet" href="../css/front.css"  />

        <title>Themes</title>
        <script language="javascript">
            function chuyen()	{
                window.location = "displayQuestion.jsp?id="+document.myform.subID.value;
            }
        </script>
    </head>


    <body bgcolor="#154978">

        <table width="1024" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" align="center">
            <!--DWLayoutTable-->
            <tr>
                <td width="1024" height="157" valign="top" background="../images/Banner.jpg">

                </td>
            </tr>
            <tr>
                <td height="463" valign="top">
                    <table width="100%" border="0" cellpadding="2" cellspacing="2">
                        <!--DWLayoutTable-->
                        <tr>
                            <td height="28" colspan="2" valign="top" background="../images/top_button.gif">
                            </td>
                        </tr>
                        <tr>
                            <td width="150" height="537" valign="top">

                                <!-- MENU -->
                                <%@include file="menu.jsp" %>
                                <!--END MENU-->	</td>
                            <td width="858" align="center" valign="top" bgcolor="#CCCCCC">
                                <h1 style="color:red">Question Content</h1>
                                <jsp:useBean id="Obj" class="DAO.DAOAdmin" scope="request" />
                                <form method="post" action="" name="myform" >

                                    <select name="subID">
                                        <option value="0">Select Question</option>
                                        <%
                                            ResultSet rss = Obj.selectSuject3();
                                            while (rss.next()) {
                                        %>
                                        <option value="<%=rss.getInt("SubID")%>"><%=rss.getString("SubName")%></option>
                                        <% }%>
                                        <input type="button" value="View Questions" name="button" onclick="chuyen()" />
                                        <input type="button" value="Add Questions" name="buttonAdd" />
                                    </select>
                                </form>
                                <div id="displayQuestion" >
                                    <!-- Start -->
                                    <form>
                                        <%
                                            ResultSet rs = null;
                                            int subID = Integer.parseInt(request.getParameter("id"));
                                            if (subID >= 1) {
                                                rs = Obj.selectQuestion2(subID);

                                            } else {
                                                rs = Obj.selectQuestion();
                                                subID = 0;
                                            }
                                        %>
                                        <table border="1" style="border:solid 1px; border-collapse:collapse">
                                            <thead>
                                                <tr>
                                                    <th>QuestionID</th>
                                                    <th>SubID</th>
                                                    <th>ContenQuestion</th>
                                                    <th>Mark</th>
                                                    <th>Status</th>
                                                    <th>Answer</th>
                                                    <th>Editter</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <%
                                                    while (rs.next()) {
                                                %>
                                                <tr>
                                                    <td><%=rs.getString(1)%></td>
                                                    <td><%=rs.getString(2)%></td>
                                                    <td>
                                                        <ajax:anchors target="displayQuestion" >
                                                            <a href="addAnswer.jsp?id=<%=rs.getString(1)%>&key=<%=subID%>" ><%=rs.getString(3)%></a>
                                                        </ajax:anchors>

                                                    </td>

                                                    <td><%=rs.getString(4)%></td>
                                                    <td>
                                                        <a href="include/displayQuestionStatus.jsp?id=<%=rs.getString(1)%>&<%if (rs.getBoolean(5) == true) {%>display=false<% } else {%>display=true<% }%>&key=<%=subID%>">
                                                            <%
                                                                if (rs.getBoolean(5) == true) {
                                                            %>
                                                           <img src="images/preview_f2.png" height="20" width="20" border="0"/>
                                                            <% } else {
                                                            %> <img src="images/unpreview_f2.png" height="20" width="20" border="0"/> <% }%>
                                                        </a>
                                                    </td>
                                                    <td>
                                                        <%
                                                            ResultSet rssr = Obj.selectAnswer(rs.getInt(1));
                                                            if (rssr.next()) {
                                                                out.println(rssr.getString("Tong"));
                                                            }
                                                        %>
                                                    </td>
                                                    <td>
                                                        <ajax:anchors target="displayQuestion" >
                                                            <a href="editQuestion.jsp?id=<%=rs.getString(1)%>&Content=<%=rs.getString("ContentQuestion")%>&Mark=<%=rs.getString("Mark")%>&key=<%=subID%>" ><img src="../images/button/system/24-tool-a.png" alt="Edit"  border="0"/></a>
                                                        </ajax:anchors>
                                                    </td>
                                                </tr>
                                                <% }%>
                                            </tbody>
                                        </table>
                                </div>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </body>
</html>
